package main.java.com.manger.service.Impl;

import com.manger.constant.Constant;
import com.manger.dao.CourseMapper;
import com.manger.entity.Course;
import com.manger.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by LCJ on 2017/6/13.
 */
@Service
public class CourseServiceImpl implements CourseService {

    @Autowired
    private CourseMapper courseMapper;

    @Override
    public String addCourse(Course course) {
        if(courseMapper.insert(course)>0)
            return Constant.OPERATEION_SUCCESS;
        return Constant.OPERATEION_FAILURE ;
    }

    @Override
    public String deleteCourse(Integer id) {
        if(courseMapper.deleteByPrimaryKey(id)>0)
            return Constant.OPERATEION_SUCCESS;
        return Constant.OPERATEION_FAILURE ;
    }

    @Override
    public String updateCourse(Course course) {
        if(courseMapper.updateByPrimaryKey(course)>0)
            return Constant.OPERATEION_SUCCESS;
        return Constant.OPERATEION_FAILURE ;
    }

    @Override
    public List<Course> findAllCourse() {
        return courseMapper.findAllCourse();
    }

    @Override
    public Course findCourse(Integer id) {
        return courseMapper.selectByPrimaryKey(id);
    }
}
